﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace FSquirrel.Helpers
{
    public class DepthSelector : DataTemplateSelector
    {
        private HierarchicalDataTemplate bottomLevel;
        private readonly List<char> _alphabet = new List<char>("#ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray());

        public DepthSelector()
        {
        }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            string _name = ((CollectionViewGroup)(item)).Name.ToString();

            if (_name.Length == 1 && _alphabet.Contains(_name[0]))
            {
                return null;
            }

            return bottomLevel;
        }

        public HierarchicalDataTemplate BottomLevel
        {
            get
            {
                return this.bottomLevel;
            }
            set
            {
                this.bottomLevel = value;
            }
        }
    }
}